//
//  WelcomePageController.m
//  KuWeiPark
//
//  Created by Kevin Su on 15/4/28.
//  Copyright (c) 2015年 Clief. All rights reserved.
//

#import "WelcomePageController.h"
#import "AppMacro.h"
#import "AppDelegate.h"
#import "HomeViewController.h"
#import "HttpClientManager.h"

@interface WelcomePageController ()

@end

@implementation WelcomePageController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.loginBtn.layer.masksToBounds = YES;
    self.loginBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    self.loginBtn.layer.cornerRadius = 5;
    self.loginBtn.layer.borderWidth = 1;
    
    self.registerBtn.layer.masksToBounds = YES;
    self.registerBtn.layer.borderColor = [UIColor whiteColor].CGColor;
    self.registerBtn.layer.cornerRadius = 5;
    self.registerBtn.layer.borderWidth = 1;
    
    self.logoTopLayoutConstraint.constant = self.view.frame.size.height * 132 / 568.0 - 64;
    self.introBottomLayoutConstraint.constant = self.view.frame.size.height * 38 / 568.0;
    self.btnsBottomLayoutConstraint.constant = self.view.frame.size.height * 22 / 568.0;
    
    [self checkLoginModel];
}

- (void)checkLoginModel{
    
    NSDictionary *loginUserDic = [[NSUserDefaults standardUserDefaults] objectForKey:NsUserDefaultKey_LoginModel];
    LoginModel *loginModel = [[LoginModel alloc] initWithDictionary:loginUserDic error:nil];
    if(loginModel.userId){
        
        ApplicationDelegate.loginModel = loginModel;
        HomeViewController *homeController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"HomeViewController"];
        [self.navigationController pushViewController:homeController animated:NO];
    }
}

- (void)viewWillAppear:(BOOL)animated{
    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
